home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 10.4 KB | 321 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWGC.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #ifndef FWGC_H
- #include "FWGC.h"
- #endif
-
- #ifndef FWGRUTIL_H
- #include "FWGrUtil.h"
- #endif
-
- #ifndef SLGRGLOB_H
- #include "SLGrGlob.h"
- #endif
-
- #ifndef FWFXMATH_H
- #include "FWFxMath.h"
- #endif
-
- #ifndef SLREGION_H
- #include "SLRegion.h"
- #endif
-
- #ifndef FWMAPING_H
- #include "FWMaping.h"
- #endif
-
- #ifndef FWODGEOM_H
- #include "FWODGeom.h"
- #endif
-
- #ifndef FWPRIDEB_H
- #include "FWPriDeb.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_ODTransform_xh
- #include <Trnsform.xh>
- #endif
-
- #ifndef SOM_ODShape_xh
- #include <Shape.xh>
- #endif
-
- #ifndef SOM_ODCanvas_xh
- #include <Canvas.xh>
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment FW_GRTransformContextSegment
- #endif
-
- //========================================================================================
- // class FW_CGraphicContext
- //========================================================================================
-
- FW_DEFINE_AUTO(FW_CGraphicContext)
-
- //----------------------------------------------------------------------------------------
- // FW_CGraphicContext::FW_CGraphicContext
- //----------------------------------------------------------------------------------------
-
- FW_CGraphicContext::FW_CGraphicContext(Environment* ev)
- {
- FW_PrivGC_Clear(ev, *this);
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CGraphicContext::InitGraphicContext
- //----------------------------------------------------------------------------------------
- // clipShape is in content coordinate
-
- FW_DECLARE_THROW_POINT (FW_CGraphicContext_InitGraphicContext);
-
- void FW_CGraphicContext::InitGraphicContext(FW_HGDevice graphicDevice,
- ODTransform* transform,
- ODShape* clipShape)
- {
- FW_PrivGC_Initialize(fEnvironment, *this, graphicDevice, transform, clipShape);
- FW_FailOnEvError(fEnvironment);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CGraphicContext::PrivReset
- //----------------------------------------------------------------------------------------
- // Used after AutoScroll
-
- void FW_CGraphicContext::PrivReset(ODTransform* transform,
- ODShape* clipShape)
- {
- FW_PrivGC_ChangeClipAndTransform(fEnvironment, *this, transform, clipShape);
- FW_FailOnEvError(fEnvironment);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CGraphicContext::TerminateGraphicContext
- //----------------------------------------------------------------------------------------
-
- void FW_CGraphicContext::TerminateGraphicContext()
- {
- FW_PrivGC_Terminate(fEnvironment, *this);
- FW_FailOnEvError(fEnvironment);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CGraphicContext::~FW_CGraphicContext
- //----------------------------------------------------------------------------------------
-
- FW_CGraphicContext::~FW_CGraphicContext()
- {
- FW_START_DESTRUCTOR
-
- TerminateGraphicContext();
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CGraphicContext::SetMapping
- //----------------------------------------------------------------------------------------
-
- void FW_CGraphicContext::SetMapping(const FW_SMapping& newMapping)
- {
- FW_PrivGC_SetMapping(fEnvironment, *this, newMapping);
- FW_FailOnEvError(fEnvironment);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CGraphicContext::GetMapping
- //----------------------------------------------------------------------------------------
-
- void FW_CGraphicContext::GetMapping(FW_CMapping& mapping) const
- {
- mapping = fMapping;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CGraphicContext::SetClip
- //----------------------------------------------------------------------------------------
-
- void FW_CGraphicContext::SetClip(ODShape* odShape) // a copy of odShape is used
- {
- FW_PrivGC_SetClip(fEnvironment, *this, odShape);
- FW_FailOnEvError(fEnvironment);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CGraphicContext::GetClipRect
- //----------------------------------------------------------------------------------------
-
- void FW_CGraphicContext::GetClipRect(FW_SRect& clipRect) const
- {
- FW_PrivGC_GetClipRect(fEnvironment, *this, clipRect);
- FW_FailOnEvError(fEnvironment);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CGraphicContext::SetClipRect
- //----------------------------------------------------------------------------------------
-
- void FW_CGraphicContext::SetClipRect(const FW_SRect& clipRect)
- {
- FW_PrivGC_SetClipRect(fEnvironment, *this, clipRect);
- FW_FailOnEvError(fEnvironment);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CGraphicContext::LogicalToDevice
- //----------------------------------------------------------------------------------------
-
- FW_CPlatformPoint FW_CGraphicContext::LogicalToDevice(FW_Fixed xSize, FW_Fixed ySize) const
- {
- FW_CPlatformPoint ptResult;
- FW_PrivGC_LogicalToDeviceSize(fEnvironment, *this, xSize, ySize, ptResult);
- FW_FailOnEvError(fEnvironment);
- return ptResult;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CGraphicContext::LogicalToDevice
- //----------------------------------------------------------------------------------------
-
- FW_CPlatformPoint FW_CGraphicContext::LogicalToDevice(const FW_CPoint& point) const
- {
- FW_CPlatformPoint plfmPoint;
- FW_PrivGC_LogicalToDevicePoint(fEnvironment, *this, point, plfmPoint);
- FW_FailOnEvError(fEnvironment);
- return plfmPoint;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CGraphicContext::LogicalToDevice
- //----------------------------------------------------------------------------------------
-
- FW_CPlatformRect FW_CGraphicContext::LogicalToDevice(const FW_CRect& rect) const
- {
- FW_CPlatformRect plfmRect;
- FW_PrivGC_LogicalToDeviceRect(fEnvironment, *this, rect, plfmRect);
- FW_FailOnEvError(fEnvironment);
- return plfmRect;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CGraphicContext::LogicalToDevice
- //----------------------------------------------------------------------------------------
-
- ODShape* FW_CGraphicContext::LogicalToDevice(ODShape* shape) const
- {
- ODShape* result = FW_PrivGC_LogicalToDeviceShape(fEnvironment, *this, shape);
- FW_FailOnEvError(fEnvironment);
- return result;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CGraphicContext::DeviceToLogical
- //----------------------------------------------------------------------------------------
-
- FW_CPoint FW_CGraphicContext::DeviceToLogical(FW_PlatformCoordinate xSize, FW_PlatformCoordinate ySize) const
- {
- FW_CPoint ptResult;
- FW_PrivGC_DeviceToLogicalSize(fEnvironment, *this, xSize, ySize, ptResult);
- FW_FailOnEvError(fEnvironment);
- return ptResult;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CGraphicContext::DeviceToLogical
- //----------------------------------------------------------------------------------------
-
- FW_CPoint FW_CGraphicContext::DeviceToLogical(const FW_CPlatformPoint& point) const
- {
- FW_CPoint pt;
- FW_PrivGC_DeviceToLogicalPoint(fEnvironment, *this, point, pt);
- FW_FailOnEvError(fEnvironment);
- return pt;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CGraphicContext::DeviceToLogical
- //----------------------------------------------------------------------------------------
-
- FW_CRect FW_CGraphicContext::DeviceToLogical(const FW_CPlatformRect& rect) const
- {
- FW_CRect rectResult;
- FW_PrivGC_DeviceToLogicalRect(fEnvironment, *this, rect, rectResult);
- FW_FailOnEvError(fEnvironment);
- return rectResult;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CGraphicContext::DeviceToLogical
- //----------------------------------------------------------------------------------------
-
- ODShape* FW_CGraphicContext::DeviceToLogical(ODShape* shape) const
- {
- ODShape* result = FW_PrivGC_DeviceToLogicalShape(fEnvironment, *this, shape);
- FW_FailOnEvError(fEnvironment);
- return result;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CGraphicContext::AcquireClip
- //----------------------------------------------------------------------------------------
-
- ODShape* FW_CGraphicContext::AcquireClip() const
- {
- ODShape* shape = FW_PrivGC_GetClip(fEnvironment, *this);
- FW_FailOnEvError(fEnvironment);
- return shape;
- }
-
- //========================================================================================
- // class FW_CSaveRestoreContext
- //========================================================================================
-
- FW_DEFINE_AUTO(FW_CSaveRestoreContext)
-
- //----------------------------------------------------------------------------------------
- // FW_CSaveRestoreContext::FW_CSaveRestoreContext
- //----------------------------------------------------------------------------------------
-
- FW_CSaveRestoreContext::FW_CSaveRestoreContext(FW_CGraphicContext& gc) :
- fGC(gc),
- fSuspendResume(NULL)
- {
- FW_ASSERT(&gc == FW_PrivGC_GetCurrent(gc.GetEnvironment()));
-
- FW_PlatformError error;
- fSuspendResume = FW_PrivGDev_Suspend(gc.fGraphicDevice, &error);
- FW_FailOnError(error);
-
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSaveRestoreContext::FW_CSaveRestoreContext
- //----------------------------------------------------------------------------------------
-
- FW_CSaveRestoreContext::~FW_CSaveRestoreContext()
- {
- FW_START_DESTRUCTOR
- FW_PlatformError error;
-
- // ----- ATTENTION: I don't own fSuspendResume so I don't delete it -----
- if (fSuspendResume)
- FW_PrivGDev_Resume(fGC.fGraphicDevice, fSuspendResume, &error);
- // [HLX] What do I do with the error
- }
-